// index.js
// 获取应用实例
const app = getApp()

Page({
  data: {
    teacher:[],
    message:""
  },
  // 事件处理函数
  bindViewTap() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad() {
    
  },
  getMessage:function (params) {
    console.log(params.detail.value)
    this.setData({
      message:params.detail.value
    })
  }
  ,
  findMessage:function(e){
    console.log("发生了sumbit事件")
    var value = e.detail.value
    console.log(value)
    //获取文本框信息
    var message = this.data.message
    console.log(message);

    var url = app.globalData.url;
    var studentId = app.globalData.studentId;
    var that = this;

    if(message==""){
      //请求为空
      wx.showModal({
        title: '提示',
        content: '输入框为空默认查询已经评教课程',
        showCancel:false
      })
      //发送请求
      wx.request({
        url: url+'/getTeacher2', 
        data: {
          studentId: studentId
        },
        header: {
          'content-type': 'application/json' // 默认值
        },
        success (res) {
          console.log(res.data)
          that.setData({
            teacher:res.data
          })
        }
      })

    }else{
      //发送请求
      wx.request({
        url: url+'/getTeacherByParam', 
        data: {
          studentId: studentId,
          message:message
        },
        header: {
          'content-type': 'application/json' // 默认值
        },
        success (res) {
          console.log(res.data)
          that.setData({
            teacher:res.data
          })
        }
      })
      console.log(that.data.teacher)
    }

  }, 
  doEvaluate:function (params) {
    var teacherCourse = params.currentTarget.dataset.teachercourse;
    var teacherName = params.currentTarget.dataset.teachername;
    var teacherEvaluateFlag = params.currentTarget.dataset.teacherevaluateflag;
    var teacherId = params.currentTarget.dataset.teacherid;
    console.log(params)
    console.log(teacherName+teacherCourse+teacherEvaluateFlag+teacherId)
    console.log("评教")
    wx.navigateTo({
      url: '../content2/content?teacherName='+teacherName+'&teacherCourse='+teacherCourse+'&teacherEvaluateFlag='+teacherEvaluateFlag+'&teacherId='+teacherId
    })
  },
 
})
